﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame.Input
{
	public class XboxInputFactory : IInputFactory
	{
		private GamePadState currGamePadState;
		private GamePadState prevGamePadState;

		public void Update(GameTime gameTime)
		{
			prevGamePadState = currGamePadState;
			currGamePadState = GamePad.GetState(PlayerIndex.One); 
		}

		public Boolean Escape()
		{
			return currGamePadState.Buttons.Back == ButtonState.Pressed;
		}
		public Boolean Toggle()
		{
			return ButtonPress(Buttons.A);
		}
		public Boolean Load()
		{
			return ButtonPress(Buttons.X);
		}

		private Boolean ButtonPress(Buttons button)
		{
			return currGamePadState.IsButtonDown(button) && prevGamePadState.IsButtonUp(button);
		}
	}
}